package ctrl

import (
	"cyiris/app/demo/biz"
	"cyiris/core/http"
	log "cyiris/core/zaplog"
)

type RedisCtrl struct {
	http.Ctrl
	biz *biz.RedisBiz
}

func NewRedisCtrl() *RedisCtrl {
	c := &RedisCtrl{
		Ctrl: http.NewBaseCtrl(),
		biz:  biz.NewRedisBiz(),
	}

	return c
}

func (ctrl *RedisCtrl) Action(ctx *http.Context) {
	log.Debugf("handle redis ctrl")

	member := ctx.FormValue("member")

	if member == "" {
		ctx.Error(-1, "params error")
		return
	}

	members, err := ctrl.biz.Handle(member)
	if nil != err {
		ctx.Error(-1, err.Error())
		return
	}

	ctx.Success(members)
}
